package org.igeek.config.di.ch01;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @package org.igeek.config.di.ch01
 * @Description 测试类
 * @Author LittlePunk [296526219@qq.ccom]
 * @Version 2022.1
 * @Date 2023/11/14 10:32
 */
public class MainTest {
    public static void main(String[] args) {
        //1.创建IOC容器
        AnnotationConfigApplicationContext ac =
                new AnnotationConfigApplicationContext(MyConfig.class);
        //2.获取实例 userController
        UserController controller = ac.getBean("controller",UserController.class);
        controller.login();


        System.out.println("------------------测试作用域----------------");
        Object u1 = ac.getBean("u");
        Object u2 = ac.getBean("u");
        System.out.println("u1.hashCode() = " + u1.hashCode());
        System.out.println("u2.hashCode() = " + u2.hashCode());
    }
}
